import request from '@/config/axios'

// ERP 库存预警规则配置 VO
export interface StockWarningRuleVO {
  id: number // 编号
  warningName: string // 预警名称
  type: string // 产品类型：成品(finished)、零部件(components)
  warningCondition: string // 预警阈值判断条件（如：<、<=、>、>=、=）
  warningValue: number // 预警阈值
  warningStatus: number // 预警状态（0: 启用，1: 未启用）
}

// ERP 库存预警规则配置 API
export const StockWarningRuleApi = {
  // 查询ERP 库存预警规则配置分页
  getStockWarningRulePage: async (params: any) => {
    return await request.get({ url: `/erp/stock-warning-rule/page`, params })
  },

  // 查询ERP 库存预警规则配置详情
  getStockWarningRule: async (id: number) => {
    return await request.get({ url: `/erp/stock-warning-rule/get?id=` + id })
  },

  // 新增ERP 库存预警规则配置
  createStockWarningRule: async (data: StockWarningRuleVO) => {
    return await request.post({ url: `/erp/stock-warning-rule/create`, data })
  },

  // 修改ERP 库存预警规则配置
  updateStockWarningRule: async (data: StockWarningRuleVO) => {
    return await request.put({ url: `/erp/stock-warning-rule/update`, data })
  },

  // 删除ERP 库存预警规则配置
  deleteStockWarningRule: async (id: number) => {
    return await request.delete({ url: `/erp/stock-warning-rule/delete?id=` + id })
  },

  // 导出ERP 库存预警规则配置 Excel
  exportStockWarningRule: async (params) => {
    return await request.download({ url: `/erp/stock-warning-rule/export-excel`, params })
  },
}